package com.um.jdy.platform.financial.controller;


import com.um.jdy.platform.financial.entity.dto.MerchantCashoutPageDTO;
import com.um.jdy.platform.financial.entity.dto.RejectDTO;
import com.um.jdy.platform.financial.entity.vo.MerchantCashoutItemVO;
import com.um.jdy.platform.financial.manager.MerchantCashoutManager;
import com.um.springboot.starter.annotation.ApiPermission;
import com.um.springboot.starter.annotation.LoginRequired;
import com.um.springboot.starter.entity.Page;
import com.um.springboot.starter.orm.controller.BaseController;
import com.um.springboot.starter.orm.entity.Response;
import com.um.springboot.starter.orm.params.PageParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * 控制器：商户提现表
 */
@RestController
@RequestMapping("/api/v1/cms/finance/merchant_cashout")
@Api(tags = "财务管理", description = "商户提现表")
@ApiPermission("merchant_cashout")
@LoginRequired
public class MerchantCashoutController extends BaseController<MerchantCashoutManager> {

    /**
     * 分页查询运营商提现记录
     * @param params
     * @return
     */
    @ApiPermission("page")
    @ApiOperation("提现记录分页")
    @PostMapping("/cashout_page")
    public Response<Page<MerchantCashoutItemVO>> getCashoutPage(@RequestBody MerchantCashoutPageDTO params){
            PageParams pageParams = params.toPageParams(
                    new String[]{"type","mobile","status","outTradeNo","platformMerchantId"},
                    new String[]{"type","me.mobile","a.status","a.out_trade_no","a.platform_merchant_id"},
                    "a.create_time","beginTime","endTime");
        return manager.getCashoutPage(pageParams);
    }

    /**
     * 提现通过
     * @param id
     * @return
     */
    @ApiPermission("pass")
    @ApiOperation("提现通过")
    @PutMapping("/{id}/pass")
    public Response cashoutPass(@PathVariable String id){
        return manager.cashoutPass(id);
    }

    /**
     * 提现拒绝
     * @param rejectDTO
     * @return
     */
    @ApiPermission("reject")
    @ApiOperation("提现拒绝")
    @PutMapping("/{id}/reject")
    public Response cashoutReject(@PathVariable String id, @RequestBody RejectDTO rejectDTO){
        return manager.cashoutReject(id,rejectDTO);
    }
}
